import QtQuick 2.0

Rectangle {
    width: 120
    height: 300
    color: "darkgray"
    radius: 20
    signal sigBtnClicked(var code)


    Column {
        spacing: 2
        anchors.horizontalCenter: parent.horizontalCenter

        SiderBtn {
            id: btnFeed
            text: "喂食"
            onSigBtnClicked: maintainBtns(text)
            Component.onCompleted: setClicked()
        }

        SiderBtn {
            id: btnSetting
            text: "设置"
            onSigBtnClicked: maintainBtns(text)
            m_imgSource: "qrc:/imgs/setting.png"
        }

        SiderBtn {
            id: btnStatistic
            text: "统计"
            onSigBtnClicked: maintainBtns(text)
            m_imgSource: "qrc:/imgs/statistic.png"
        }

//        Rectangle {
//            height: 1000
//            width: btn2.width
//            color: "darkgray"
//        }
    }

    function maintainBtns(btnTextIn) {
        var btns = [btnFeed, btnSetting, btnStatistic]
        btns.forEach(item => {
                         if (item.text !== btnTextIn)
                         {
                             item.restoreColor()
                         }
                     })

        emit: sigBtnClicked(btnTextIn)
    }
}

